package com.net.framework.help.manager;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

/***
 * 公共跳转管理
 *
 * @author zhangxiaobin
 */
public class JumpManager extends Intent {
    private static JumpManager intent;

    public JumpManager() {
    }

    /**
     * Intent单一实例
     */
    public static JumpManager getInstance() {
        if (intent == null) {
            intent = new JumpManager();
        }
        return intent;
    }

    /**
     * 无参跳转
     *
     * @param context
     * @param _class
     */
    public void jumpFromTo(Context context, Class<?> _class) {
        intent.setClass(context, _class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    /**
     * 带参跳转
     *
     * @param context
     * @param _class
     * @param bundle
     */
    public void jumpFromTo(Context context, Class<?> _class, Bundle bundle) {
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        jumpFromTo(context, _class);
    }

    /**
     * 带参回执结果跳转
     *
     * @param activity
     * @param _class
     * @param bundle
     * @param resultCode
     */
    public void jumpFromResult(Activity activity, Class<?> _class, Bundle bundle, int resultCode) {
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        jumpFromResult(activity, _class, resultCode);
    }

    /**
     * 无参回执结果跳转
     *
     * @param activity
     * @param _class
     * @param resultCode
     */
    public void jumpFromResult(Activity activity, Class<?> _class, int resultCode) {
        intent.setClass(activity, _class);
        activity.startActivityForResult(intent, resultCode);
    }
}
